package edu.hrbeu.crc.aiTools;

import edu.hrbeu.crc.pojo.dto.BillDTO;
import edu.hrbeu.crc.pojo.query.BillChatQuery;
import edu.hrbeu.crc.pojo.query.BillSaveQuery;
import edu.hrbeu.crc.pojo.vo.BillChatVO;
import edu.hrbeu.crc.service.BillService;
import lombok.RequiredArgsConstructor;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import java.util.List;

@RequiredArgsConstructor
@Component
public class BillTool {

    private final BillService billService;


    @Tool(description = "根据条件查询账单")
    public List<BillChatVO> queryBills(@ToolParam(description = "查询的条件") BillChatQuery query) {
        return this.billService.queryBills(query);
    }

    @Tool(description = "添加账单，并返回是否添加成功")
    public boolean addBills(@ToolParam(description = "添加账单") BillSaveQuery query) {
        BillDTO billDTO = new BillDTO();
        BeanUtils.copyProperties(query, billDTO);
        return this.billService.add(billDTO);
    }
}
